package com.example.qxfw.hbqx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.qxfw.common.entity.qx.ImportantWeather;
import com.example.qxfw.common.entity.qx.MsgMediumSmallScale;
import com.example.qxfw.common.entity.qx.MsgMediumSmallScaleTemp;
import com.example.qxfw.common.entity.qx.SmallScaleStation;
import com.example.qxfw.common.entity.zy.AirpolLiveQx;
import com.example.qxfw.common.entity.zy.EnviroStation;
import com.example.qxfw.hbqx.mapper.AirpolLiveQxMapper;
import com.example.qxfw.hbqx.mapper.ImportantWeatherMapper;
import com.example.qxfw.hbqx.mapper.MsgMediumSmallScaleTempMapper;
import com.example.qxfw.hbqx.service.QxjcService;
import com.example.qxfw.rcyw.mapper.SmallScaleStationMapper;
import com.example.qxfw.ybzz.mapper.EnviroStationMapper;
import com.example.qxfw.ybzz.mapper.MsgMediumSmallScaleMapper;
import com.example.qxfw.ybzz.mapper.YbzzConfigMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class QxjcServiceImpl implements QxjcService {
    @Autowired
    private AirpolLiveQxMapper airpolLiveQxMapper;
    @Autowired
    private SmallScaleStationMapper smallScaleStationMapper;
    @Autowired
    private MsgMediumSmallScaleTempMapper msgMediumSmallScaleTempMapper;
    @Autowired
    private EnviroStationMapper enviroStationMapper;
    @Autowired
    private ImportantWeatherMapper importantWeatherMapper;
    @Autowired
    private YbzzConfigMapper ybzzConfigMapper;
    @Autowired
    private MsgMediumSmallScaleMapper msgMediumSmallScaleMapper;






    /**
     * 降序获取观测时间
     * @return
     */
    @Override
    public List<AirpolLiveQx> getObservtime() {
        return airpolLiveQxMapper.getObservtime();
    }
    /**
     * 根据市县和站点id查询站点名字和id
     * @param stationid 站点id
     * @param city 城市
     * @param county 县
     * @return
     */
    @Override
    public List<SmallScaleStation> selectByStationIdAndCityAndNotCounty(String stationid, String city, String county) {
        return smallScaleStationMapper.selectByStationIdAndCityAndNotCounty(stationid, city, county);
    }

    /**
     *根据观测时间段查询站点id，名字，和时间
     * @param observtimeStart 观测时间起点
     * @param observtimeEnd 观测时间终点
     * @return
     */
    @Override
    public List<MsgMediumSmallScaleTemp> selectByObservtimeOfMsgMediumSmallScaleTemp(Date observtimeStart, Date observtimeEnd) {
        return msgMediumSmallScaleTempMapper.selectByObservtimeOfMsgMediumSmallScaleTemp(observtimeStart,observtimeEnd);
    }

    /**
     * 通过站点名字查询站点id
     * @param stationname 站点名字
     * @return
     */
    @Override
    public List<EnviroStation> selectByStationNameOfEnviroStation(String stationname) {
        return enviroStationMapper.selectByStationNameOfEnviroStation(stationname);
    }

    @Override
    public List<MsgMediumSmallScaleTemp> selectByObservtimeDsitOfMsgMediumSmallScaleTemp(Date observtimeStart, Date observtimeEnd) {
        return msgMediumSmallScaleTempMapper.selectByObservtimeDsitOfMsgMediumSmallScaleTemp(observtimeStart, observtimeEnd);
    }

    /**
     * 根据站点名字和天气类型查询观测时间
     * @param weathertype 天气类型
     * @param stationname 站点名字
     * @return
     */
    @Override
    public List<ImportantWeather> selectByWeatherTypeAndStationNameOfImportantWeather(String weathertype, String stationname) {
        return importantWeatherMapper.selectByWeatherTypeAndStationNameOfImportantWeather(weathertype, stationname);
    }

    /**
     * 根据天气类型，站点名字和观测时间段查询信息
     * @param observetimeStart 观测时间起点
     * @param observetimeEnd 观测时间终点
     * @param weathertype 天气类型
     * @param stationname 站点名字
     * @return
     */
    @Override
    public List<ImportantWeather> selectByWeatherTypeAndStationNameAndObservetimeOfImportantWeather(Date observetimeStart, Date observetimeEnd, String weathertype, String stationname) {
        return importantWeatherMapper.selectByWeatherTypeAndStationNameAndObservetimeOfImportantWeather(observetimeStart, observetimeEnd, weathertype, stationname);
    }

    /**
     * 根据时间段获取雾霾能见度
     * @param observtimeStart 开始时间
     * @param observtimeEnd 结束时间
     * @return
     */
    @Override
    public List<MsgMediumSmallScale> selectByTimePeriodOfMsgMediumSmallScale(Date observtimeStart, Date observtimeEnd) {
        return msgMediumSmallScaleMapper.selectList(new LambdaQueryWrapper<MsgMediumSmallScale>()
        .between(MsgMediumSmallScale::getObservtime, observtimeStart, observtimeEnd));
    }

    /**
     * 获取所有自动站实况主表信息
     * @return
     */
    @Override
    public List<MsgMediumSmallScale> getAllOfMsgMediumSmallScale() {
        return msgMediumSmallScaleMapper.selectList(null);
    }

    /**
     * 区域自动站站点表信息
     * @return
     */
    @Override
    public List<SmallScaleStation> getAllOfSmallScaleStation() {
        return smallScaleStationMapper.selectList(null);
    }

    @Override
    public List<MsgMediumSmallScale> selectByTimePeriodAndElementAndStationIdOfMsgMediumSmallScale(Date observtimeStart, Date observtimeEnd, String element, String stationid) {
        return null;
    }


}
